<template>
	<view class="evaluateList-wrap">
		<view class="doctorInfo-evaluate" v-if="commentList.length > 0">
			<u-title :value="'患者评价（' + commentList.length + '）'"></u-title>
			<view class="section7" v-for="(item, index) in commentList" :key="index">
				<view class="box7">
					<view class="box7-txt">{{ item.patientName }}</view>
					<uni-rate readonly :value="item.star" />
				</view>
				<text lines="1" decode="true" class="word11">{{ item.content }}</text>
				<text lines="1" decode="true" class="txt2">{{ item.createdTime }}</text>
			</view>
		</view>
		
		<u-empty-state v-if="commentList.length == 0" value="暂无相关评价"></u-empty-state>
	</view>
</template>

<script>
import uniRate from '@/components/uni/uni-rate/uni-rate.vue';
import uTitle from '@/components/u-title/u-title.vue';
import uEmptyState from '@/components/u-empty-state/u-empty-state.vue';
export default {
	components: {
		uTitle,
		uniRate,
		uEmptyState
	},
	data() {
		return {
			type: 0, //0医生的患者评价，1自己的患者评价
			doctorId: null,
			commentList: []
		};
	},
	onLoad(option) {
		this.type = option.type ? option.type : 0;

		this.doctorId = option.doctorId ? option.doctorId : null;
		
	},
	onShow() {
		
		if (this.type == 0) {
			this.queryCommentList();
		} else {
			this.commentyMyList()
		}
	},
	methods: {
		//医师的评论列表
		queryCommentList() {
			this.$api
				.queryCommentList({
					params: {
						doctorId: this.doctorId,
						pageNo: 1,
						pageSize: 999
					}
				})
				.then(res => {
					if (res.code == 200) {
						this.commentList = res.result.records;
					} else {
						uni.showToast({
							title: res.message,
							icon: 'none'
						});
					}
				});
		},

		//患者自己的评论列表
		commentyMyList() {
			this.$api.commentyMyList({}).then(res => {
				if (res.code == 200) {
					this.commentList = res.result.records;
				} else {
					uni.showToast({
						title: res.message,
						icon: 'none'
					});
				}
			});
		}
	}
};
</script>

<style lang="less">
@import './evaluateList.less';
</style>
